<template>
	<div>
		<img :src="item.url" alt width="100%" />
		<h3>{{ item.title }}</h3>
		<p>{{ item.price }}</p>
	</div>
</template>

<script>
import axios from 'axios'
export default {
	data() {
		return {
			id: this.$route.params.id,
			item: {}
		}
	},
	created() {
		axios.post(`/api/posts/${this.id}`).then(resp => {
			const { code, data, mess } = resp.data
			if (code === 200) {
				this.item = data
			} else {
				alert(mess)
				this.$router.push('/')
			}
		})
	}
}
</script>